﻿Imports Microsoft.Xna.Framework
Imports Microsoft.Xna.Framework.Graphics

Public Class MenuItem
    Private mText As String
    Private mCallBack As SimpleCallback
    Private mPosition As Vector2
    Private mMenu As BasicMenu

    Public Sub New(ByVal Menu As BasicMenu, ByVal Text As String, ByVal CallBack As SimpleCallback, ByVal Position As Vector2)
        mText = Text
        mMenu = Menu
        mCallBack = CallBack
        mPosition = Position
    End Sub

    Public Sub Draw()
        With mMenu.GameManager
            .SpriteBatch.DrawString(.Font, mText, mPosition, Color.White)
            If mMenu.SelectedIndex = mMenu.Items.IndexOf(Me) Then
                ' This could be regarded as game specific. Should be extracted out to a sub class - not in the game engine
                .SpriteBatch.Draw(.Sprites("SelectHandCurrentFocus"), mPosition - New Vector2(.Sprites("SelectHandCurrentFocus").Width + 5, -18), Color.White)
            End If
        End With
    End Sub

    Public Sub HandleInput(ByVal input As IGamePadInputManager)
        If input.APressed OrElse input.MainSelectPressed OrElse input.StartPressed Then
            mMenu.GameManager.PlaySound("Click")
            mMenu.Result = mCallBack
            mMenu.Result.Invoke()
        End If
    End Sub
End Class